import Vue from 'vue'
import store from '@/store'

/** 权限指令**/
const WxRole = Vue.directive('wx-role', {
  // 当被绑定的元素插入到 DOM 中时……
  inserted: function (el, binding) {
    // 获取指令按钮权限
    const characteristic = binding.value
    // 获取路由按钮权限
    if (!binding.value) {
      return true
    }
    if (!store.getters.checkBtnPermissions(characteristic)) {
      el.parentNode.removeChild(el)
    }
  }
})

export { WxRole }
